let cancelBook = require('../Component/cancelBook');

describe('cancelBook()', () => {

    it('User cancelled failure should return message', () => {
        let customerList = {
            "A": {
                "2017-08-01": {
                    "today": "workday",
                    "usedTime": ["18:00~20:00"],
                    "cancelled": ["19:00~22:00"],
                    "U003": ["18:00~20:00"]
                }
            }
        };
        let data = {
            user: 'u123',
            date: '2016-06-04',
            time: '9:00~13:00',
            space: 'A'
        };
        let actual = cancelBook.cancelBook(customerList,data);
        let result = "Error: the booking being cancelled does not exist";
        expect(actual).toBe(result);
    });
    it('User cancelled success should return customerList', () => {
        let customerList = {
            "A": {
                "2017-08-01": {
                    "today": "workday",
                    "usedTime": ["9:00~13:00"],
                    "cancelled": ["19:00~22:00"],
                    "U003": ["9:00~13:00"]
                }
            }
        };
        let data = {
            user: 'U003',
            date: '2017-08-01',
            time: '9:00~13:00',
            space: 'A'
        };
        let actual = cancelBook.cancelBook(customerList,data);
        let result ={
            "A": {
                "2017-08-01": {
                    "today": "workday",
                    "usedTime": [],
                    "cancelled": ["19:00~22:00","9:00~13:00"]
                }
            }
        };
        expect(JSON.stringify(actual)).toBe(JSON.stringify(result));
    });
});